<template>
  <el-checkbox-group v-bind="$myProps"
                     v-on="$myListeners">
    <form-checkbox v-for="(checkbox,index) in myOptions"
                 :key="index"
                 :display="display"
                 :label="checkbox[props.value]">{{$t(checkbox[props.label])}}</bl-form-checkbox>
    </form-checkbox>
  </el-checkbox-group>
</template>

<script>
export default {
  components: {
    FormCheckbox: () => import("./checkbox"),
  },
  props: {
    //单选值
    value: [String, Number, Boolean, Array],
    //选项列表
    options: {
      type: [Array, Function, Object],
      required: true,
    },
    display: {
      type: String,
      default: "",
    },
    //选项属性定义
    props: {
      type: Object,
      default() {
        return {
          label: "label",
          value: "value",
        };
      },
    },
    objSource: {
      type: [Object],
    },
  },
  computed: {
    $myProps() {
      return this.$public.inheritProps(this);
    },
    $myListeners() {
      return this.$public.inheritListeners(this);
    },
    myOptions() {
      var objSource = this.objSource || this.options;

      let options = this.$core.convertOptions({
        options: this.options,
        props: this.props,
        objSource,
      });

      return options;
    },
  },
  mounted() {
    this.$emit("mounted");
  },
  created() {
    this.$emit("created");
  },
};
</script>